package com.guet.game.utils;

import com.guet.game.airplanes.dao.FlyingObj;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class Images {
    private static final String folder = "/com/guet/resources/";

    public static BufferedImage[] sky;
    public static BufferedImage[] bullet;
    public static BufferedImage[] hero;
    public static BufferedImage[] airplanes;
    public static BufferedImage[] bigAirplanes;
    public static BufferedImage[] giftAirplanes;

    public static BufferedImage hpFill;
    public static BufferedImage hpBg;

    public static BufferedImage start;
    public static BufferedImage pause;
    public static BufferedImage gameover;

    public static BufferedImage[] booms;
    public static BufferedImage[] boss;

    public static BufferedImage[] bossHP;
 	public static BufferedImage healItems;
    public static BufferedImage damageItems;
    
    public static BufferedImage[] atkFire;

    static {
        sky = new BufferedImage[2];
        hero = new BufferedImage[2];
        bossHP = new BufferedImage[2];
        airplanes = new BufferedImage[2];
        bigAirplanes = new BufferedImage[2];
        giftAirplanes = new BufferedImage[2];
        bullet = new BufferedImage[4];
        atkFire= new BufferedImage[4];

        healItems = readImage(folder + "healItem0" + ".png");
        damageItems = readImage(folder + "damageItem0" + ".png");

        for (int i = 0; i < hero.length; i++) {
            sky[i] = readImage(folder + "background" + i + ".png");
            hero[i] = readImage(folder + "hero" + i + ".png");
            giftAirplanes[i] = readImage(folder + "bee" + i + ".png");
            airplanes[i] = readImage(folder + "airplane" + i + ".png");
            bigAirplanes[i] = readImage(folder + "bigairplane" + i + ".png");
            bossHP[i]=readImage(folder+"boss_hp"+i+".png");
        }

      hpFill = readImage(folder + "hp_fil.png");
        hpBg = readImage(folder + "hp.png");

        for (int i = 0; i < bullet.length; i++){
            bullet[i] = readImage(folder + "bullet" + i + ".png");
        }

          start = readImage(folder + "start.png");
        pause = readImage(folder + "pause.png");
        gameover = readImage(folder + "gameover.png");
        booms = new BufferedImage[4];
        for (int i = 1; i < booms.length + 1; i++) {
            booms[i - 1] = readImage(folder + "bom" + i + ".png");
            atkFire[i - 1] = readImage(folder + "fire" + i + ".png");
        }
        boss=new BufferedImage[6];
        for (int i = 0; i < boss.length; i++) {
        	boss[i] = readImage(folder + "BOOS" + i + ".png");
        }
    }


    public static BufferedImage readImage(String fileName) {
        try {
            BufferedImage img = ImageIO.read(FlyingObj.class.getResource(fileName));
            return img;
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println(e + " " + fileName);
            return null;
        }
    }
}
